<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <main><form action="" method="post">
        <h1></h1>
    </form></main>
    <script src="./js/utils.js"></script>
    <script>
        var form  =document.querySelector('form');
        form.onsubmit=function(e){
            e.preventDefault();
            var data=serializeKeyValue(this);
            var xhr =new XMLHttpRequest();
            xhr.onreadystatechange=function(){
                if (xhr.readyState==4){
                    if (xhr.status>=200&&xhr.status<300||xhr.status==304){
                        window.location.href='01-首页.html';
                    }
                }
            }
            xhr.open("POST","http://localhost:3008/api/student/addStudent");
            xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
            xhr.send(data);
        }
    </script>
</body>
</html>